#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

#include "pr_exit.h"

/**
* 打印进程终止状态
*/
void pr_exit(int status) {
    if (WIFEXITED(status)) {
        printf("normal termination, exit status = %d\n", WEXITSTATUS(status));
    }
    else if (WIFSIGNALED(status)) {
        printf("abnormal termination, signal number = %d%s\n", 
                WTERMSIG(status), 
#ifdef WCOREDUMP
                WCOREDUMP(status) ? "(core file generatred)" : "");
#else
        "");
#endif
    }
    else if(WIFSTOPPED(status)) {
        printf("abnormal termination, signal number = %d\n", 
        WSTOPSIG(status));
    }
}

